﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using YaAppoint.Rooms;

namespace YaAppoint.Web.Controllers
{
    public class RoomsController(IRoomsAppService roomsAppService) : AbpController
    {
        private readonly IRoomsAppService _roomsAppService = roomsAppService;

        /// <summary>
        /// 获取科室诊室列表
        /// </summary>
        [HttpGet("/api/rooms/get-depart-rooms")]
        public async Task<IActionResult> GetDepartmentRooms(Guid depId, string? filterName, int page, int pageSize)
        {
            return new JsonResult(await _roomsAppService.GetDepartmentRooms(depId, filterName, page, pageSize));
        }

        /// <summary>
        /// 获取诊室详情
        /// </summary>
        [HttpGet("/api/rooms/get")]
        public async Task<IActionResult> GetAsync(Guid id)
        {
            return new JsonResult(await _roomsAppService.GetAsync(id));
        }

        /// <summary>
        /// 提交新建
        /// </summary>
        [HttpPost("/api/rooms/submit-create")]
        public async Task<IActionResult> SubmitCreate([FromBody] CreateRoomDto dto, [FromQuery] Guid depId)
        {
            return new JsonResult(await _roomsAppService.SubmitCreate(dto,depId));
        }

        /// <summary>
        /// 提交编辑
        /// </summary>
        [HttpPost("/api/rooms/submit-edit")]
        public async Task<IActionResult> SubmitEdit([FromBody]RoomDto dto, [FromQuery] Guid depId)
        {
            return new JsonResult(await  _roomsAppService.SubmitEdit(dto,depId));
        }

        /// <summary>
        /// 批量删除
        /// </summary>
        [HttpPost("/api/rooms/delete-many")]
        public async Task<IActionResult> DeleteMany([FromBody] List<Guid> idList)
        {
            return new JsonResult( await _roomsAppService.DeleteMany(idList));
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpGet("/api/rooms/delete")]
        public async Task<IActionResult> Delete(Guid id)
        {
            return new JsonResult(await _roomsAppService.Delete(id));
        }
    }
}
